<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Supporters in Hattrick</title>
</head>
<body>
<?php

include_once('database.inc.php');
include_once('track.inc.php');
include_once('functions.inc.php');
include_once('dropdowns.inc.php');

$updates = array_reverse(array_merge(
	array(
	        "2005-06-16",
	        "2005-07-08",
	        "2005-07-28",
	        "2005-08-24",
	        "2005-09-08",
	        "2005-09-29",
	        "2005-10-19",
	        "2005-11-09",
	        "2005-12-01",
	        "2005-12-23",
	        "2006-01-13",
	        "2006-02-03",
	        "2006-02-20",
	        "2006-03-13",
	        "2006-04-03"
	),
	getAllUpdates()
));

$updates = array_reverse($updates);

hit();

$dbh = connect_db("dbm");

for ($i = 0; $i < count($updates); $i++) {
	$query = mysql_query("SELECT COUNT(*) num FROM `teams_{$updates[$i]}` WHERE userid > 0") or die (mysql_error());
	$result = mysql_fetch_array($query);
	$total = $result['num'];
	$query = mysql_query("SELECT COUNT(*) sups FROM `teams_{$updates[$i]}` WHERE hassupporter = 1") or die (mysql_error());
	$result = mysql_fetch_array($query);
	$sups = $result['sups'];
	$perc = round($sups/$total*100,2);
	echo "{$updates[$i]}: $total users, $sups supporters: $perc%<br />\n";
	ob_flush();
	flush();
}
?>
</body>
</html>
